<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="__CSS__/pintuer.css?v={$src_version}">
<link rel="stylesheet" href="__CSS__/admin.css?v={$src_version}">
<link rel="stylesheet" href="__CSS__/responsive.css?v={$src_version}">
<script src="__JS__/jquery-3.2.1.min.js?v={$src_version}"></script>
<script src="__JS__/pintuer.js?v={$src_version}"></script>
<script src="https://cdn.bootcss.com/jquery.nicescroll/3.7.6/jquery.nicescroll.js"></script>
<script src="__PUBLIC__/layer.js?v={$src_version}"></script>
<script src="__JS__/ming.js?v={$src_version}"></script>
<script src="__JS__/ifram_scroll.js?v={$src_version}"></script>
<script src="__JS__/responsive.js?v={$src_version}"></script>
<body>
<div class="panel admin-panel">
<div class="padding">   
  <form method="post" action="{:U('Order/index')}?act=search" class="search-form" id="frm1">
      <ul class="search">
       <li>
          <input type="text" value="{$con.keywords}" placeholder="请输入员工姓名" name="keywords" class="input search-input" />
         </li>
        <li>   
         <a href="javascript:void(0)" class="button border-main icon-search" id="dosearch"  style="padding: 10px 15px;"> 搜索</a>
         
         </li>
      </ul>
      
    </form>  
      
    </div>
    
    
    <table class="table table-hover text-center table-two">
      <tr>
        <th>  </th>
        <th style="text-align:left;">商品名称</th>
        <th>商品图片</th>
        <th>兑换积分</th>
        <th>姓名</th>
        <th>兑换日期</th>
        <th>状态</th>
        <th>操作</th>
      </tr>
      <volist name="goods" id="v">
        <tr>
          <td style="text-align:left; padding-left:20px;">
          <input type="checkbox" name="id[]" value="{$v.grid}" />
        </td>
          <td style="text-align:left;">{$v.grname}</td>
          <td style=" height:50px;">
          <a href="/{$v.grpics}" target="_blank">
          <img src="/{$v.grpics}"  style="display:block; margin:0 auto; height:100%; width:auto; overflow:hidden;" />
          </a>
          </td>
          <td>{$v.grpoint}</td>
          <td>{$v.realname}</td>
          <td>{$v.grtime|date='Y-m-d H:i',###}</td>
          <td><if condition="$v['is_get'] eq '0'"><i style="color:#f00; font-style:normal;">未领取</i><else /><i style=" color:#060;font-style:normal;">已领取</i></if></td>
          <td> 
          <div class="button-group"> 
          <a class="button border-main" href="{:U('Order/add')}?id={$v.grid}"><span class="icon-edit"></span> 修改状态</a> 
          <a class="button border-red" href="javascript:void(0)" onclick="return del({$v.grid})"><span class="icon-trash-o"></span> 删除</a> 
          </div>
          </td>
        </tr>
        </volist>
  
 <?php if(intval(count($goods))>0){ ?>
 
         
   <tr  class="no-hover">
        <td style="text-align:left; padding:19px 0;padding-left:20px;">
        <input type="checkbox" id="checkall"/>
					全选 
					<a class="button border-main" id="many-edit"><span class="icon-edit"></span> 批量修改</a> 
				</td>
        <td colspan="80" style="text-align:left;padding-left:20px;"><a href="javascript:void(0)" class="button border-red icon-trash-o" style="padding:5px 15px;" onclick="DelSelect()"> 删除</a> 
       
          </td>
      </tr>
      
       <tr  class="no-hover" style="border-bottom:none"> <td style="border-bottom:none" colspan="80"><div class="pagelist"><?php echo $page; ?></div></td></tr>  
          
      <?php }else{ ?>  
        
         <tr  class="no-hover"><td style="border-bottom:none" colspan="80"><div class="pagelist"><?php  echo '暂无记录'; ?></div></td></tr> 
                     
      <?php } ?>  
    </table>
  </div>
	<div id="order" style="display: none;padding: 10px">
		<form class="layer-form" id="form1" action=" " name="form1" method="POST">
			<div class='layer-form-item'>
				<label class='layer-form-label' style="width: 60px">状态：</label>
				<div class='layer-input-inline'>
						<select class='layer-select' name='receive' id='receive' style="width: 140px;">
							<option value='0'>未领取</option>
							<option value='1'>已领取</option>
						</select>
				</div>
			</div>
			<div class="layer-form-item">
				<div class="layer-input-block" style="margin: 0 auto;text-align: center;">
					<input class="layer-btn" type="submit" id="order-submit" value="确认修改">
				</div>
			</div>
		</form>
	</div>


</body>
</html>
<script type="text/javascript">
	$(function(){
		 //搜索
		$('#dosearch').click(function(){$('#frm1').submit();} );  
	});
	//单个删除
	function del(id){
		layer.confirm('您确定要删除吗?', {
					btn: ['确定','取消'] //按钮
			 }, function(){
			//执行删除操作
				$.ajax({
				type:'post',
				url:"{:U('Order/del')}",
				data:{id:id},
				dataType:'json',
				success:function(res){
					layer.msg(res.msg, {icon: res.code});
					res.code=='1'?setTimeout("goURL('"+res.url+"')",500):'';
				}
			});
			 });
	}
	//全选
	$("#checkall").click(function(){ 
	
		if(this.checked)
			{   
							$("input[name='id[]']").each(function(){
									this.checked = true;
					});
			 }
			 else
			 {   
					$("input[name='id[]']").each(function(){
									this.checked = false;
					});
			}   
	});
	//设置全选复选框
	$("input[name='id[]']").click(function(){
		allchk();
	});
	function allchk(){
	 
		var chknum= $("input[name='id[]']").length;//选项总个数
		var chk = 0;
		$("input[name='id[]']").each(function () {  
					if($(this).prop("checked")==true){
				chk++;
			}
			});
		if(chknum==chk){
			//全选
			$("#checkall").prop("checked",true);
		}else{
			//不全选
			$("#checkall").prop("checked",false);
		}
	}
	//批量删除
	function DelSelect(){
		var Checkbox=false;
		var chk_id_arr=[];
		 $("input[name='id[]']").each(function(){
			if (this.checked==true) {		
			Checkbox=true;	
			chk_id_arr.push($(this).val());
			}
		});
		if (Checkbox){
			layer.confirm('您确认要删除选中的记录吗?', {
					btn: ['确定','取消'] //按钮
			 }, function(){
			//执行删除操作
		 $.ajax({
			 type:'post',
			 url:"{:U('Order/del')}",
			 data:{id:chk_id_arr},	
			 dataType:'json',
			 success:function(res){
				 layer.msg(res.msg, {icon: res.code});
				 res.code=='1'?setTimeout("goURL('"+res.url+"')",500):'';
				 }
			});
			 });
		}
		else{
			layer.alert('请选择您要删除的记录!', {
			closeBtn: 0});
			 return false;
		}
	}
	
	 $('#many-edit').click(function(){
		 var edit=false;
		$("input[name='id[]']").each(function () {  
			if($(this).prop("checked")==true){
				edit=true;
				return ;
			}
		})
		if(!edit){
			layer.alert('请选择您要删除的记录!', {closeBtn: 0});
		}else{
			layer.open({
				title:'操作',
				type: 1,
				content: $('#order'),
			});
		}
		
	 })
	 $('#order-submit').click(function(){
		var ids=[];
		var receive=$("#receive option:selected").val();
		$("input[name='id[]']").each(function () {  
				if($(this).prop("checked")==true){
				ids.push($(this).val());
			}
			return ids;
		})
		console.log(receive);
		console.log(ids);
		$.ajax({ 
			url: "{:U('order/status_ajax')}",
			data:{
				ids:ids,
				status:receive
			},
			success: function(){
				if(data.code==200){
					layer.alert('请选择您要删除的记录!', {closeBtn: 0});
				}
			}
		});
	 })
	</script>
	
	 